package com.yupi.yupicturebackend.config;


import com.qcloud.cos.COSClient;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
;

@ConfigurationProperties(prefix = "cos.client")
@Configuration
@Data
public class ClientConfig {

    String host;
    String secretId;
    String secretKey;
    String region;
    String bucketName;
    @Bean
    public COSClient getCosClient() {

        COSCredentials cred = new BasicCOSCredentials(secretId,secretKey);
        // 2 设置 bucket 的区域, COS 地域的简称请参照

        com.qcloud.cos.ClientConfig clientConfig = new com.qcloud.cos.ClientConfig(new Region(region));
        // 3 生成 cos 客户端。
      COSClient cosClient = new COSClient(cred,clientConfig);
        return cosClient;
    }
}
